from selenium.webdriver.common.by import By

from xueqiu_app_po.base.xueqiu_app import XueQiuApp
from xueqiu_app_po.page.show_result_page import ShowResultPage


class SearchPage(XueQiuApp):
    _SEARCH_INPUT =By.ID, "com.xueqiu.android:id/search_input_text"

    def input_search(self,name):
        # 输入搜索内容
        self.find_and_send_keys(*self._SEARCH_INPUT,name)
        _ELEMENTS = By.XPATH, f"//*[@text='{name}']"

        # 点击第一个搜索选项
        # 将找到的三个放到el3列表中
        result = self.finds(*_ELEMENTS)
        # 选取第二个元素去点击
        result[1].click()
        return ShowResultPage(self.driver)
